package function

import (
	"GraduationProject/public/models"
	"GraduationProject/public/params"
	"GraduationProject/worker/fengchedm/fetcher/normal"
	"GraduationProject/worker/fengchedm/parser"
	"GraduationProject/worker/worker_tools"
)

var visited bool

func Anime(seed models.Record) (result params.Result) {
	content, err := normal.Get(seed.Url)
	if err != nil {
		seed.Error = err.Error()
		return params.Result{
			Result: []models.Record{
				seed,
			},
		}
	}

	//fmt.Println("content:",string(content)[:50])

	result.Seeds, result.Result = parser.Anime(seed, content)
	//fmt.Println(result)
	//rst, err := json.Marshal(&result)
	//fmt.Printf("result:%s %v\n", string(rst), err)
	if !visited {
		worker_tools.Visited(seed)
	}
	return result
}
